<?php 
namespace Admin\Controller;

/**
 * 文章发布控制器
 * @since   1.0
 * @version 1.0
 * @date    2015年3月27日
 * @author  zhanglei<firenzelei@163.com>
 */
class ArticlePublishController extends SystemController
{
    public $model = "ArticlePublish";
    
    public function _before_add()
    {
        $classifyList = D('ArticleClassify') -> getClassifyList();
        $this -> assign('classifyList',$classifyList);
    }
    
    public function _before_insert()
    {
        $_POST['show_time'] = strtotime($_POST['show_time']);
        //添加管理员id
        $_POST['admin_id'] = admin_id();
    }
    
    public function _before_edit()
    {
        $classifyList = D('ArticleClassify') -> getClassifyList();
        $this -> assign('classifyList',$classifyList);
    }
    
    public function _before_update()
    {
        $_POST['show_time'] = strtotime($_POST['show_time']);
    }
    
    /*
     * 检查文章的唯一标识是否有重复
     *  
     * @return  string   
     * @author  zhanglei<firenzelei@163.com>
     */
    public function checkIdentify()
    {
        $identify = I('post.identify','');
        $vals = D('ArticlePublish') -> getField('identify',true);
        echo in_array($identify,$vals,true) ? 'false' : 'success';
    }
    
}